﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WowDotNetAPI.Models;

namespace WowDotNetAPI.Explorers.Test
{
    [TestClass]
    public class AuctionTests : SilverlightTest
    {
        private static WowExplorer explorer;

        [ClassInitialize]
        public static void ClassInit(TestContext context)
        {
            explorer = new WowExplorer(Region.US, Locale.en_US);
        }

        [TestMethod]
        [Asynchronous]
        public void testUsRealm()
        {
            bool done = false;
            Auctions auctions=null;
            WowExplorer realmExplorer = new WowExplorer(Region.US, Locale.en_US, "", "");
            realmExplorer.GetAuctions("Skullcrusher", cb =>
            {
                auctions = cb.Result;
                done = true;
            });

            EnqueueConditional(() => done);
            EnqueueCallback(() => Assert.IsTrue(auctions.Horde.Auctions.Count() > 0));
            EnqueueTestComplete();
        }

        [TestMethod]
        [Asynchronous]
        public void testEuRealm()
        {
            WowExplorer realmExplorer = new WowExplorer(Region.EU, Locale.en_US, "", "");
            realmExplorer.Region = Region.EU;
           
            bool done = false;
            Auctions auctions = null;
            realmExplorer.GetAuctions("Twisting Nether", cb =>
            {
                auctions = cb.Result;
                done = true;
            });

            EnqueueConditional(() => done);
            EnqueueCallback(() => Assert.IsTrue(auctions.Horde.Auctions.Count() > 0));
            EnqueueTestComplete();
        }

        [TestMethod]
        [Asynchronous]
        public void testTwRealm()
        {
            WowExplorer realmExplorer = new WowExplorer(Region.TW, Locale.en_US, "", "");
            realmExplorer.Region = Region.TW;

            bool done = false;
            Auctions auctions = null;
            realmExplorer.GetAuctions("Balnazzar", cb =>
            {
                auctions = cb.Result;
                done = true;
            });

            EnqueueConditional(() => done);
            EnqueueCallback(() => Assert.IsTrue(auctions.Horde.Auctions.Count() > 0));
            EnqueueTestComplete(); 
       }
    }
}